let cmd = getUrlParamVal('cmd')
if (cmd) {
    try {
        let words = CryptoJS.enc.Base64.parse(cmd.replace(/\s/g, ''));
        cmd = CryptoJS.enc.Utf8.stringify(words)
    } catch (e) {
        cmd = ''
    }
}

window.TerminalWin = new TerminalWin({
    selector: $('#WebTerminalMainWin'),
    editor: $('#WebTerminalEditorWin'),
    history_id: 'interface',
    init_cmd: cmd
});
window.EditorWin = new EditorWin({
    selector: '#WebTerminalEditorWin',
    terminal: window.TerminalWin
});

api_runtime_on_message_listener((msg, sender, response) => {
    if (sender.origin == "null") {
        messageHandle(msg, sender, response);
    }
});

// var editor = CodeMirror.fromTextArea(document.getElementById("codeEditor"), {  // 标识到textarea
//     mode: "javascript",  // 模式
//     theme: "monokai",  // CSS样式选择
//     indentUnit: 4,  // 缩进单位，默认2
//     smartIndent: true,  // 是否智能缩进
//     tabSize: 4,  // Tab缩进，默认4
//     matchBrackets: true,
//     showCursorWhenSelecting: true,
//     // lint: true,
//     foldGutter: true,
//     lineWrapping: true, //代码折叠
//     gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgetter"],
//     extraKeys: { "Ctrl": "autocomplete" },//ctrl可以弹出选择项
//     lineNumbers: true  // 是否显示行号
// });

// function getCustom() {
//     var str = '<li><a href="/main.html">控制台</a></li>';
//     $('#custom-list').html(str)
// }

// $(function () {
//     getCustom()
// })